<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.Map.Entry" %>
<%@page import="com.faf.bean.Food"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort() + path+"/"+"UserGlobal"+"/";
%>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>饭否-首页</title>
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/reset.css">
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/main.css">
	<script type="text/javascript" src="<%=basePath%>js/jquery-1.12.4.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/jquery-ui.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/slide.js"></script>
</head>
<% 
	Object pre_global_info_user_name = request.getSession().getAttribute("account");
	String global_info_user_name;
	HashMap<Integer, Integer> global_info_cart_id2count = null;
	int i_food_count = 0;
	
	if(null != pre_global_info_user_name){
		global_info_user_name = pre_global_info_user_name.toString();
		global_info_cart_id2count = (HashMap<Integer, Integer>)request.getSession().getAttribute("global_cart");
		for(int value : global_info_cart_id2count.values())
			i_food_count += value;
		
	} else {
		global_info_user_name = "";
	}
	
	request.getSession().setAttribute("pre-page", "/FAFCode/Index");
%>
<body>
<% 
	Object pre_index_dat = request.getAttribute("index_dat_over");
	if(null == pre_index_dat) {
%>
	<jsp:forward page="/Index"/>
<%
	} else { 
		HashMap<String, ArrayList<Food>> hash_type2food = (HashMap<String, ArrayList<Food>>)request.getAttribute("index_dat_foodmap");
%>
	<div class="header_con">
		<div class="header">
			<div class="welcome fl">欢迎来到饭否!</div>
			<div class="fr">
				<div class="login_info fl">
					欢迎您：<em><%= null == pre_global_info_user_name ? global_info_user_name : "请登录" %></em>
				</div>
				<% if(null == pre_global_info_user_name) { %>
				<div class="login_btn fl">
					<a href="/FAFCode/UserManagement/login.jsp">登录</a>
					<span>|</span>
					<a href="/FAFCode/UserManagement/register.jsp">注册</a>
				</div>
				<% } else { %>
				<div class="user_link fl">
					<a href="/FAFCode/UserLogout">注销</a>
					<span>|</span>
					<a href="/FAFCode/UserManagement/user_center_info.jsp">用户中心</a>
					<span>|</span>
					<a href="/FAFCode/MyCart">我的购物车</a>
					<span>|</span>
					<a href="/FAFCode/UserManagement/user_center_order.jsp">我的订单</a>
				</div>
				<% } %>
			</div>
		</div>		
	</div>

	<div class="search_bar clearfix">
		<a href="Index" class="logo fl"><img src="/FAFCode/Image/logo/logo.png"></a>
		<form action="List" >
		<div class="search_con fl">
			<input type="text" class="input_text fl" name="serchContect" placeholder="搜索商品">
			<input type="submit" class="input_btn fr" name="" value="搜索">
		</div>
		</form>
		<div class="guest_cart fr">
			<a href="/FAFCode/MyCart" class="cart_name fl">我的购物车</a>
			<div class="goods_count fl" id="show_count"><%=i_food_count %></div>
		</div>
	</div>

	<div class="navbar_con">
		<div class="navbar">
			<h1 class="fl">全部商品分类</h1>
			<ul class="navlist fl">
				<li><a href="">首页</a></li>
				<li class="interval">|</li>
				<li><a href="">手机生鲜</a></li>
				<li class="interval">|</li>
				<li><a href="">抽奖</a></li>
			</ul>
		</div>
	</div>

	<div class="center_con clearfix">
		<ul class="subnav fl">
			<li><a href="#model01" class="fruit">炒菜</a></li>
			<li><a href="#model02" class="seafood">主食</a></li>
			<li><a href="#model03" class="meet">凉菜</a></li>
			<li><a href="#model04" class="egg">饮品</a></li>
			<li><a href="#model05" class="vegetables">速食</a></li>
			<li><a href="#model06" class="ice">水果</a></li>
		</ul>
		<div class="slide fl">
			<ul class="slide_pics">
				<li><img src="<%=basePath%>images/slide.jpg" alt="幻灯片"></li>
				<li><img src="<%=basePath%>images/slide02.jpg" alt="幻灯片"></li>
				<li><img src="<%=basePath%>images/slide03.jpg" alt="幻灯片"></li>
				<li><img src="<%=basePath%>images/slide04.jpg" alt="幻灯片"></li>
			</ul>
			<div class="prev"></div>
			<div class="next"></div>
			<ul class="points"></ul>
		</div>
		<div class="adv fl">
			<a href="#"><img src="<%=basePath%>images/adv01.jpg"></a>
			<a href="#"><img src="<%=basePath%>images/adv02.jpg"></a>
		</div>
	</div>

	<div class="list_model">
		<div class="list_title clearfix">
			<h3 class="fl" id="model01">炒菜</h3>
			<a href="List?flag=1" class="goods_more fr" id="fruit_more">查看更多 ></a>
		</div>

		<div class="goods_con clearfix">
			<div class="goods_banner fl"><a href="List?flag=1"><img src="/FAFCode/Image/foodType/banner01.jpg"></a></div>
			<ul class="goods_list fl">
			
				<%
				ArrayList<Food> foodList_chaocai = hash_type2food.get("炒菜"); 
				if(null != foodList_chaocai){
				for(Food food : foodList_chaocai){
				%>
				
				<li>
				<h4><a href="Detail?fid=<%=food.getFoodId() %>"><%= food.getFoodName() %></a></h4>
				<a href="Detail?fid=<%=food.getFoodId() %>"><img src="<%= "/FAFCode/"+food.getFoodPhoto() %>"></a>
				<div class="prize">¥ <%= food.getFoodPrice() %></div>
				</li>
				
				<%	
				}}
				%>
				
			</ul>
		</div>
	</div>

	<div class="list_model">
		<div class="list_title clearfix">
			<h3 class="fl" id="model02">主食</h3>
			<a href="List?flag=2" class="goods_more fr">查看更多 ></a>
		</div>

		<div class="goods_con clearfix">
			<div class="goods_banner fl"><a href="List?flag=2"><img src="/FAFCode/Image/foodType/banner02.jpg"></a></div>
			<ul class="goods_list fl">
				
				<%
				ArrayList<Food> foodList_zhushi = hash_type2food.get("主食"); 
				if(null != foodList_zhushi){
				for(Food food : foodList_zhushi){
				%>
				
				<li>
				<h4><a href="Detail?fid=<%=food.getFoodId() %>"><%= food.getFoodName() %></a></h4>
				<a href="Detail?fid=<%=food.getFoodId() %>"><img src="<%= "/FAFCode/"+food.getFoodPhoto() %>"></a>
				<div class="prize">¥ <%= food.getFoodPrice() %></div>
				</li>
				
				<%	
				}}
				%>
				
			</ul>
		</div>
	</div>

	<div class="list_model">
		<div class="list_title clearfix">
			<h3 class="fl" id="model03">凉菜</h3>
			<a href="List?flag=3" class="goods_more fr">查看更多 ></a>
		</div>

		<div class="goods_con clearfix">
			<div class="goods_banner fl"><a href="List?flag=3"><img src="/FAFCode/Image/foodType/banner03.jpg"></a></div>
			<ul class="goods_list fl">
				
				<%
				ArrayList<Food> foodList_liangcai = hash_type2food.get("凉菜"); 
				if(null != foodList_liangcai){
				for(Food food : foodList_liangcai){
				%>
				
				<li>
				<h4><a href="Detail?fid=<%=food.getFoodId() %>"><%= food.getFoodName() %></a></h4>
				<a href="Detail?fid=<%=food.getFoodId() %>"><img src="<%= "/FAFCode/"+food.getFoodPhoto() %>"></a>
				<div class="prize">¥ <%= food.getFoodPrice() %></div>
				</li>
				
				<%	
				}}
				%>

			</ul>
		</div>
	</div>

	<div class="list_model">
		<div class="list_title clearfix">
			<h3 class="fl" id="model04">饮品</h3>
			<a href="List?flag=4" class="goods_more fr">查看更多 ></a>
		</div>

		<div class="goods_con clearfix">
			<div class="goods_banner fl"><a href="List?flag=4"><img src="/FAFCode/Image/foodType/banner04.jpg"></div>
			<ul class="goods_list fl">

				<%
				ArrayList<Food> foodList_yinpin = hash_type2food.get("饮品"); 
				if(null != foodList_yinpin){
				for(Food food : foodList_yinpin){
				%>
				
				<li>
				<h4><a href="Detail?fid=<%=food.getFoodId() %>"><%= food.getFoodName() %></a></h4>
				<a href="Detail?fid=<%=food.getFoodId() %>"><img src="<%= "/FAFCode/"+food.getFoodPhoto() %>"></a>
				<div class="prize">¥ <%= food.getFoodPrice() %></div>
				</li>
				
				<%	
				}}
				%>

			</ul>
		</div>
	</div>

	<div class="list_model">
		<div class="list_title clearfix">
			<h3 class="fl" id="model05">速食</h3>
			<a href="List?flag=5" class="goods_more fr">查看更多 ></a>
		</div>

		<div class="goods_con clearfix">
			<div class="goods_banner fl"><a href="List?flag=5"><img src="/FAFCode/Image/foodType/banner05.jpg"></a></div>
			<ul class="goods_list fl">
			
				<%
				ArrayList<Food> foodList_sushi = hash_type2food.get("速食"); 
				if(null != foodList_sushi){
				for(Food food : foodList_sushi){
				%>
				
				<li>
				<h4><a href="Detail?fid=<%=food.getFoodId() %>"><%= food.getFoodName() %></a></h4>
				<a href="Detail?fid=<%=food.getFoodId() %>"><img src="<%= "/FAFCode/"+food.getFoodPhoto() %>"></a>
				<div class="prize">¥ <%= food.getFoodPrice() %></div>
				</li>
				
				<%	
				}}
				%>
			
			</ul>
		</div>
	</div>

	<div class="list_model">
		<div class="list_title clearfix">
			<h3 class="fl" id="model06">水果</h3>
			<a href="List?flag=6" class="goods_more fr">查看更多 ></a>
		</div>

		<div class="goods_con clearfix">
			<div class="goods_banner fl"><a href="List?flag=6"><img src="/FAFCode/Image/foodType/banner06.jpg"></a></div>
			<ul class="goods_list fl">
			
				<%
				ArrayList<Food> foodList_shuiguo = hash_type2food.get("水果"); 
				if(null != foodList_shuiguo){
				for(Food food : foodList_shuiguo){
				%>
				
				<li>
				<h4><a href="Detail?fid=<%=food.getFoodId() %>"><%= food.getFoodName() %></a></h4>
				<a href="Detail?fid=<%=food.getFoodId() %>"><img src="<%= "/FAFCode/"+food.getFoodPhoto() %>"></a>
				<div class="prize">¥ <%= food.getFoodPrice() %></div>
				</li>
				
				<%	
				}}
				%>
			
			</ul>
		</div>
	</div>

	<div class="footer">
		<div class="foot_link">
			<a href="#">关于我们</a>
			<span>|</span>
			<a href="#">联系我们</a>
			<span>|</span>
			<a href="#">招聘人才</a>
			<span>|</span>
			<a href="#">友情链接</a>		
		</div>
		<p>CopyRight © 2020 南昌航空大学713 All Rights Reserved</p>
		<p>江西省南昌市丰和南大道696号</p>
		<p>https://www.nchu.edu.cn/</p>
	</div>
	<% } %>
	<script type="text/javascript" src="<%=basePath%>js/slideshow.js"></script>
	<script type="text/javascript">
		BCSlideshow('focuspic');
		var oFruit = document.getElementById('fruit_more');
		var oShownum = document.getElementById('show_count');

		var hasorder = localStorage.getItem('order_finish');

		if(hasorder)
		{
			oShownum.innerHTML = '2';
		}

		oFruit.onclick = function(){
			window.location.href = 'list.html';
		}
	</script>
</body>
</html>